﻿<Activity mc:Ignorable="sap sap2010 sads" x:Class="Artezio.SP.WorkflowActions.ResetRoleInheritance"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
 xmlns:p="http://schemas.microsoft.com/workflow/2012/07/xaml/activities"
 xmlns:p1="wf://workflow.windows.net/$Activities"
 xmlns:s="clr-namespace:System;assembly=mscorlib"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
 xmlns:sn="clr-namespace:System.Net;assembly=System"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <x:Members>
    <x:Property Name="SecurableObjectApiPath" Type="InArgument(x:String)">
      <x:Property.Attributes>
        <RequiredArgumentAttribute />
      </x:Property.Attributes>
    </x:Property>
  </x:Members>
  <sap2010:ExpressionActivityEditor.ExpressionActivityEditor>C#</sap2010:ExpressionActivityEditor.ExpressionActivityEditor>
  <sap2010:WorkflowViewState.IdRef>Artezio.SP.WorkflowActions.ResetRoleInheritance_1</sap2010:WorkflowViewState.IdRef>
  <TextExpression.NamespacesForImplementation>
    <sco:Collection x:TypeArguments="x:String">
      <x:String>System</x:String>
      <x:String>System.Collections.Generic</x:String>
      <x:String>System.Data</x:String>
      <x:String>System.Text</x:String>
      <x:String>Microsoft.Activities</x:String>
      <x:String>System.Net</x:String>
    </sco:Collection>
  </TextExpression.NamespacesForImplementation>
  <TextExpression.ReferencesForImplementation>
    <sco:Collection x:TypeArguments="AssemblyReference">
      <AssemblyReference>Microsoft.Activities</AssemblyReference>
      <AssemblyReference>Microsoft.CSharp</AssemblyReference>
      <AssemblyReference>Microsoft.SharePoint.DesignTime.Activities</AssemblyReference>
      <AssemblyReference>PresentationCore</AssemblyReference>
      <AssemblyReference>PresentationFramework</AssemblyReference>
      <AssemblyReference>System</AssemblyReference>
      <AssemblyReference>System.Activities</AssemblyReference>
      <AssemblyReference>System.Activities.Presentation</AssemblyReference>
      <AssemblyReference>System.Core</AssemblyReference>
      <AssemblyReference>System.Data</AssemblyReference>
      <AssemblyReference>System.Drawing</AssemblyReference>
      <AssemblyReference>System.Runtime.Serialization</AssemblyReference>
      <AssemblyReference>System.ServiceModel.Activities</AssemblyReference>
      <AssemblyReference>System.Xaml</AssemblyReference>
      <AssemblyReference>System.Xml</AssemblyReference>
      <AssemblyReference>System.Xml.Linq</AssemblyReference>
      <AssemblyReference>Microsoft.SharePoint</AssemblyReference>
      <AssemblyReference>Microsoft.SharePoint.Client.ServerRuntime</AssemblyReference>
      <AssemblyReference>WindowsBase</AssemblyReference>
      <AssemblyReference>mscorlib</AssemblyReference>
      <AssemblyReference>Artezio.SP.WorkflowActions</AssemblyReference>
    </sco:Collection>
  </TextExpression.ReferencesForImplementation>
  <Sequence DisplayName="Reset Role Inheritance" sap2010:WorkflowViewState.IdRef="Sequence_1">
    <Sequence.Variables>
      <Variable x:TypeArguments="x:String" Name="errorMessage" />
      <Variable x:TypeArguments="x:String" Name="logToHistory" />
      <Variable x:TypeArguments="p:DynamicValue" Name="resetRoleInheritanceResponse" />
      <Variable x:TypeArguments="sn:HttpStatusCode" Name="resetRoleInheritanceStatus" />
      <Variable x:TypeArguments="x:String" Default="/resetRoleInheritance()" Name="resetRoleInheritanceMethodName" />
    </Sequence.Variables>
    <If DisplayName="Check if SecurableObjectApiPath is empty" sap2010:WorkflowViewState.IdRef="If_5">
      <If.Condition>
        <InArgument x:TypeArguments="x:Boolean">
          <mca:CSharpValue x:TypeArguments="x:Boolean">string.IsNullOrWhiteSpace(SecurableObjectApiPath)</mca:CSharpValue>
        </InArgument>
      </If.Condition>
      <If.Then>
        <Sequence sap2010:WorkflowViewState.IdRef="Sequence_4">
          <p1:AppOnlySequence DisplayName="Write to history" sap2010:WorkflowViewState.IdRef="AppOnlySequence_3">
            <p1:AppOnlySequence.Body>
              <p1:WriteToHistory sap2010:WorkflowViewState.IdRef="WriteToHistory_5" Message="ResetRoleInheritance Exception: SecurableObjectApiPath can not be empty" />
            </p1:AppOnlySequence.Body>
          </p1:AppOnlySequence>
          <Throw sap2010:WorkflowViewState.IdRef="Throw_2">
            <InArgument x:TypeArguments="s:Exception">
              <mca:CSharpValue x:TypeArguments="s:Exception">new ArgumentException("ResetRoleInheritance Exception: SecurableObjectApiPath can not be empty")</mca:CSharpValue>
            </InArgument>
          </Throw>
        </Sequence>
      </If.Then>
    </If>
    <Sequence DisplayName="MakeApiCall" sap2010:WorkflowViewState.IdRef="Sequence_5">
      <Assign sap2010:WorkflowViewState.IdRef="Assign_1">
        <Assign.To>
          <OutArgument x:TypeArguments="x:String">
            <mca:CSharpReference x:TypeArguments="x:String">errorMessage</mca:CSharpReference>
          </OutArgument>
        </Assign.To>
        <Assign.Value>
          <InArgument x:TypeArguments="x:String">
            <Literal x:TypeArguments="x:String" Value="" />
          </InArgument>
        </Assign.Value>
      </Assign>
      <p1:AppOnlySequence sap2010:WorkflowViewState.IdRef="AppOnlySequence_1">
        <p1:AppOnlySequence.Body>
          <p:HttpSend sap2010:WorkflowViewState.IdRef="HttpSend_1" Method="POST">
            <p:HttpSend.RequestHeaders>
              <InArgument x:TypeArguments="p:DynamicValue">
                <p:SetDynamicValueProperties>
                  <scg:Dictionary x:TypeArguments="x:String, InArgument">
                    <InArgument x:TypeArguments="x:String" x:Key="Accept">application/json; odata=verbose</InArgument>
                    <InArgument x:TypeArguments="x:String" x:Key="Content-Type">application/json; odata=verbose</InArgument>
                  </scg:Dictionary>
                </p:SetDynamicValueProperties>
              </InArgument>
            </p:HttpSend.RequestHeaders>
            <p:HttpSend.ResponseContent>
              <OutArgument x:TypeArguments="p:DynamicValue">
                <mca:CSharpReference x:TypeArguments="p:DynamicValue">resetRoleInheritanceResponse</mca:CSharpReference>
              </OutArgument>
            </p:HttpSend.ResponseContent>
            <p:HttpSend.ResponseStatusCode>
              <OutArgument x:TypeArguments="sn:HttpStatusCode">
                <mca:CSharpReference x:TypeArguments="sn:HttpStatusCode">resetRoleInheritanceStatus</mca:CSharpReference>
              </OutArgument>
            </p:HttpSend.ResponseStatusCode>
            <p:HttpSend.Uri>
              <InArgument x:TypeArguments="x:String">
                <mca:CSharpValue x:TypeArguments="x:String">SecurableObjectApiPath + resetRoleInheritanceMethodName</mca:CSharpValue>
              </InArgument>
            </p:HttpSend.Uri>
          </p:HttpSend>
        </p1:AppOnlySequence.Body>
      </p1:AppOnlySequence>
      <If DisplayName="Check response status code" sap2010:WorkflowViewState.IdRef="If_4">
        <If.Condition>
          <InArgument x:TypeArguments="x:Boolean">
            <mca:CSharpValue x:TypeArguments="x:Boolean">resetRoleInheritanceStatus != HttpStatusCode.OK</mca:CSharpValue>
          </InArgument>
        </If.Condition>
        <If.Then>
          <Sequence sap2010:WorkflowViewState.IdRef="Sequence_3">
            <p:GetDynamicValueProperty x:TypeArguments="x:String" sap2010:WorkflowViewState.IdRef="GetDynamicValueProperty`1_2" PropertyName="error/message/value">
              <p:GetDynamicValueProperty.Result>
                <OutArgument x:TypeArguments="x:String">
                  <mca:CSharpReference x:TypeArguments="x:String">errorMessage</mca:CSharpReference>
                </OutArgument>
              </p:GetDynamicValueProperty.Result>
              <p:GetDynamicValueProperty.Source>
                <InArgument x:TypeArguments="p:DynamicValue">
                  <mca:CSharpValue x:TypeArguments="p:DynamicValue">resetRoleInheritanceResponse</mca:CSharpValue>
                </InArgument>
              </p:GetDynamicValueProperty.Source>
            </p:GetDynamicValueProperty>
            <If sap2010:WorkflowViewState.IdRef="If_2">
              <If.Condition>
                <InArgument x:TypeArguments="x:Boolean">
                  <mca:CSharpValue x:TypeArguments="x:Boolean">string.IsNullOrWhiteSpace(errorMessage)</mca:CSharpValue>
                </InArgument>
              </If.Condition>
              <If.Then>
                <Assign sap2010:WorkflowViewState.IdRef="Assign_2">
                  <Assign.To>
                    <OutArgument x:TypeArguments="x:String">
                      <mca:CSharpReference x:TypeArguments="x:String">errorMessage</mca:CSharpReference>
                    </OutArgument>
                  </Assign.To>
                  <Assign.Value>
                    <InArgument x:TypeArguments="x:String">
                      <mca:CSharpValue x:TypeArguments="x:String">String.Format("The server responded with a status of {0} ({1}). Request Uri: {2}", (int)resetRoleInheritanceStatus, resetRoleInheritanceStatus, SecurableObjectApiPath + resetRoleInheritanceMethodName)</mca:CSharpValue>
                    </InArgument>
                  </Assign.Value>
                </Assign>
              </If.Then>
            </If>
            <Assign sap2010:WorkflowViewState.IdRef="Assign_3">
              <Assign.To>
                <OutArgument x:TypeArguments="x:String">
                  <mca:CSharpReference x:TypeArguments="x:String">errorMessage</mca:CSharpReference>
                </OutArgument>
              </Assign.To>
              <Assign.Value>
                <InArgument x:TypeArguments="x:String">
                  <mca:CSharpValue x:TypeArguments="x:String">"ResetRoleInheritance Exception: " + errorMessage</mca:CSharpValue>
                </InArgument>
              </Assign.Value>
            </Assign>
            <If sap2010:WorkflowViewState.IdRef="If_3">
              <If.Condition>
                <InArgument x:TypeArguments="x:Boolean">
                  <mca:CSharpValue x:TypeArguments="x:Boolean">errorMessage.Length &gt; 255</mca:CSharpValue>
                </InArgument>
              </If.Condition>
              <If.Then>
                <Assign sap2010:WorkflowViewState.IdRef="Assign_4">
                  <Assign.To>
                    <OutArgument x:TypeArguments="x:String">
                      <mca:CSharpReference x:TypeArguments="x:String">logToHistory</mca:CSharpReference>
                    </OutArgument>
                  </Assign.To>
                  <Assign.Value>
                    <InArgument x:TypeArguments="x:String">
                      <mca:CSharpValue x:TypeArguments="x:String">errorMessage.Substring(0, 252) + "..."</mca:CSharpValue>
                    </InArgument>
                  </Assign.Value>
                </Assign>
              </If.Then>
              <If.Else>
                <Assign sap2010:WorkflowViewState.IdRef="Assign_5">
                  <Assign.To>
                    <OutArgument x:TypeArguments="x:String">
                      <mca:CSharpReference x:TypeArguments="x:String">logToHistory</mca:CSharpReference>
                    </OutArgument>
                  </Assign.To>
                  <Assign.Value>
                    <InArgument x:TypeArguments="x:String">
                      <mca:CSharpValue x:TypeArguments="x:String">errorMessage</mca:CSharpValue>
                    </InArgument>
                  </Assign.Value>
                </Assign>
              </If.Else>
            </If>
            <p1:AppOnlySequence DisplayName="Write to history" sap2010:WorkflowViewState.IdRef="AppOnlySequence_4">
              <p1:AppOnlySequence.Body>
                <p1:WriteToHistory sap2010:WorkflowViewState.IdRef="WriteToHistory_3">
                  <p1:WriteToHistory.Message>
                    <InArgument x:TypeArguments="x:String">
                      <mca:CSharpValue x:TypeArguments="x:String">logToHistory</mca:CSharpValue>
                    </InArgument>
                  </p1:WriteToHistory.Message>
                </p1:WriteToHistory>
              </p1:AppOnlySequence.Body>
            </p1:AppOnlySequence>
            <Throw sap2010:WorkflowViewState.IdRef="Throw_1">
              <InArgument x:TypeArguments="s:Exception">
                <mca:CSharpValue x:TypeArguments="s:Exception">new ArgumentException(errorMessage)</mca:CSharpValue>
              </InArgument>
            </Throw>
          </Sequence>
        </If.Then>
      </If>
    </Sequence>
    <p1:AppOnlySequence DisplayName="Write to history" sap2010:WorkflowViewState.IdRef="AppOnlySequence_2">
      <p1:AppOnlySequence.Body>
        <p1:WriteToHistory sap2010:WorkflowViewState.IdRef="WriteToHistory_4" Message="ResetRoleInheritance: Completed" />
      </p1:AppOnlySequence.Body>
    </p1:AppOnlySequence>
    <sads:DebugSymbol.Symbol>d3NDOlxBbGlzYVxXb3JrZmxvd0FjdGlvbnNTYW5kYm94ZWRcQXJ0ZXppby5TUC5Xb3JrZmxvd0FjdGlvbnNcQWN0aW9uc1xSZXNldFJvbGVJbmhlcml0YW5jZVxSZXNldFJvbGVJbmhlcml0YW5jZS54YW1sNjsD9gEOAgEBQTRBTQIBAkMFVwoDAaEBWAXvARACAQbwAQX0ARoCAQNGC0Z7AwGiAUoJVRQDAakBWQdkEAMBmAFlB4MBHAIBfYQBB+4BDAIBB/IBCfIBewIBBEsLTyADAbIBUAtUEwMBqgFhDWE8AwGgAVwNXF8DAZkBZwuBARgCAX6HAQ2HAXsCAQiLAQvsARYCAQ/yAVfyAXgCAQVND02pAQMBswFSD1KwAQMBqwFqEW8vAwGVAXkReXoDAY4BfhF+hgEDAYcBdBF0eQMBgAFnS2dRAgF/jAENlwEpAgFtmAENrAESAgFWrQENuAEWAgFHuQEN2wESAgEh3AEN5gEiAgEY5wEN6wEVAgEQTV1NpgEDAbQBbEtsagMBlwFtUW1wAwGWAY8BE48BZQIBdpQBE5QBcwIBb4wBjgGMAaMBAgFumwETmwF5AgFXnwERqgEaAgFetQETtQGCAQIBT7ABE7ABZQIBSLwBE7wBbgIBIsABEcsBGgIBOM4BEdkBGgIBKd4BEeQBJQIBGekBEekBdQIBEacBF6cBnQICAWaiAReiAWkCAV/IARfIAXsCAUDDARfDAWkCATnWARfWAWECATHRARfRAWkCASrhARfhAWECARo=</sads:DebugSymbol.Symbol>
  </Sequence>
  <sap2010:WorkflowViewState.ViewStateManager>
    <sap2010:ViewStateManager>
      <sap2010:ViewStateData Id="WriteToHistory_5" sap:VirtualizedContainerService.HintSize="200,68" />
      <sap2010:ViewStateData Id="AppOnlySequence_3" sap:VirtualizedContainerService.HintSize="226,148">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Throw_2" sap:VirtualizedContainerService.HintSize="226,22" />
      <sap2010:ViewStateData Id="Sequence_4" sap:VirtualizedContainerService.HintSize="248,334">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="If_5" sap:VirtualizedContainerService.HintSize="264,49">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">False</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Assign_1" sap:VirtualizedContainerService.HintSize="242,59" />
      <sap2010:ViewStateData Id="HttpSend_1" sap:VirtualizedContainerService.HintSize="200,59" />
      <sap2010:ViewStateData Id="AppOnlySequence_1" sap:VirtualizedContainerService.HintSize="242,148" />
      <sap2010:ViewStateData Id="GetDynamicValueProperty`1_2" sap:VirtualizedContainerService.HintSize="509,22" />
      <sap2010:ViewStateData Id="Assign_2" sap:VirtualizedContainerService.HintSize="242,62" />
      <sap2010:ViewStateData Id="If_2" sap:VirtualizedContainerService.HintSize="509,212">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Assign_3" sap:VirtualizedContainerService.HintSize="509,62" />
      <sap2010:ViewStateData Id="Assign_4" sap:VirtualizedContainerService.HintSize="242,62" />
      <sap2010:ViewStateData Id="Assign_5" sap:VirtualizedContainerService.HintSize="242,62" />
      <sap2010:ViewStateData Id="If_3" sap:VirtualizedContainerService.HintSize="509,212" />
      <sap2010:ViewStateData Id="WriteToHistory_3" sap:VirtualizedContainerService.HintSize="200,68" />
      <sap2010:ViewStateData Id="AppOnlySequence_4" sap:VirtualizedContainerService.HintSize="509,148">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Throw_1" sap:VirtualizedContainerService.HintSize="509,22" />
      <sap2010:ViewStateData Id="Sequence_3" sap:VirtualizedContainerService.HintSize="531,1002">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="If_4" sap:VirtualizedContainerService.HintSize="242,49">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">False</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Sequence_5" sap:VirtualizedContainerService.HintSize="264,460">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="WriteToHistory_4" sap:VirtualizedContainerService.HintSize="200,68" />
      <sap2010:ViewStateData Id="AppOnlySequence_2" sap:VirtualizedContainerService.HintSize="264,49">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">False</x:Boolean>
            <x:Boolean x:Key="IsPinned">False</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="286,762">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Artezio.SP.WorkflowActions.ResetRoleInheritance_1" sap:VirtualizedContainerService.HintSize="326,842" />
    </sap2010:ViewStateManager>
  </sap2010:WorkflowViewState.ViewStateManager>
</Activity>